import 'package:flutter/material.dart';
import 'package:ball_lion/resources/styles.dart';

class QsText extends StatelessWidget {
  const QsText(this.data,
      {super.key,
      this.noData = "",
      this.fontSize,
      this.color,
      this.fontWeight,
      this.shimmer = true,
      this.shimmerCount = 5,
      this.maxLines,
      this.height,
      this.needCenter = false,
      this.fontFamily,
      this.textAlign,
      this.decoration,
      this.letterSpacing,
      this.textWidthBasis,
      this.shadows,
      this.decorationStyle})
      : style = null;

  QsText.style(
    this.data, {
    super.key,
    this.noData = "",
    this.style,
    this.shimmer = true,
    this.shimmerCount = 5,
    this.maxLines,
    this.needCenter = false,
    this.textAlign,
    this.textWidthBasis,
  })  : fontSize = style?.fontSize ?? 14,
        color = style?.color,
        fontFamily = style?.fontFamily,
        fontWeight = style?.fontWeight ?? FontWeight.w400,
        height = style?.height,
        letterSpacing = style?.letterSpacing,
        shadows = style?.shadows,
        decorationStyle = style?.decorationStyle,
        decoration = style?.decoration;

  final String? data;
  final String noData;
  //style
  final double? fontSize;
  final Color? color;
  final TextAlign? textAlign;
  final FontWeight? fontWeight;
  final double? letterSpacing;
  final List<Shadow>? shadows;
  final double? height;
  final TextDecoration? decoration;
  final String? fontFamily;
  final TextDecorationStyle? decorationStyle;
  //style
  final int? maxLines;
  final bool needCenter;
  final bool shimmer;
  final TextStyle? style;
  final int shimmerCount;
  final TextWidthBasis? textWidthBasis;

  TextStyle get innerStyle =>
      style ??
      TextStyle(
          fontSize: fontSize,
          color: color,
          fontWeight: fontWeight,
          fontFamily: fontFamily,
          height: height,
          letterSpacing: letterSpacing,
          shadows: shadows,
          decorationStyle: decorationStyle,
          decoration: decoration);

  @override
  Widget build(BuildContext context) {
    return Text(data ?? noData,
        textAlign: textAlign,
        maxLines: maxLines,
        softWrap: maxLines == null ? null : true,
        overflow: maxLines == null ? null : TextOverflow.ellipsis,
        strutStyle: needCenter ? Styles.centerStyle(fontSize: fontSize) : null,
        textWidthBasis: textWidthBasis,
        style: innerStyle);
  }
}
